<template>
	<div class="information bg-f5">
		<ul class="bg-white" v-if="data">
			<li class="container border-b pt10 pb10 ">					
				<!-- <div class="size_list layout pt20rem pb20rem pl30rem pr30rem border-b">
					<div class="flex_1 layout" @click='changeAvatar'>
						<div class="fs30rem c333">头像</div>
						<div class="layout">
							<input type="file" id="avatar" name='avatar' @change="upload" style="display: none;">
							<img class="member-head" src="userInfo.user_heading">
							<i class="iconfont icon-right2 fs20rem ml30rem color999"></i>
						</div>
					</div>
				</div>	 -->	
				<van-uploader multiple class="layout"  :after-read="onRead">
					<div class="fs14 black">头像</div>
					<p class="layout">
						<img class="circle mr10" style="width:30px;height: 30px;" :src="data.user_headimg" v-if="data.user_headimg"> 
						<img class="circle mr10" style="width:30px;height: 30px;" src="../../../assets/avatar2.png" v-else>
						<van-icon class="black" color="#000" size="20px" name="youjiantou"/>
					</p>
				</van-uploader>			
			</li> 
			<li class="container border-b pt15 pb15 layout" @click="show = true">					
				<div class="fs14 black">昵称</div>
				<p>
					<span class="fs14 black">{{ data.nick_name }}</span>
					<van-icon class="black" color="#000" size="20px" name="youjiantou"/>
				</p>
			</li>
			<router-link tag="li" to="/login/security/replace-phone" class="container border-b pt15 pb15 layout">					
				<div class="fs14 black">手机号</div>
				<p>
					<span class="fs14 black">{{ data.phone }}</span>
					<van-icon class="black" color="#000" size="20px" name="youjiantou"/>
				</p>
			</router-link>
			<router-link tag="li" to="/login/banding-email" class="container border-b20 pt15 pb15 layout">					
				<div class="fs14 black">绑定邮箱</div>
				<p>
					<span class="fs14 black">{{ data.email_verified == '0'? '未绑定' : data.email_verified }}</span>
					<van-icon class="black" color="#000" size="20px" name="youjiantou"/>
				</p>
			</router-link>
			<router-link tag="li" to="/login/authentication" class="container border-b20 pt15 pb15 layout">					
				<div class="fs14 black">资料认证</div>
				<p>
					<span class="subject fs14">
						<template v-if="data.rz_status == 0">
							未认证
						</template>
						<template v-if="data.rz_status == 1">
							审核中
						</template>
						<template v-if="data.rz_status == 2">
							已认证
						</template>
						<template v-if="data.rz_status == 3">
							认证失败
						</template>
					</span>
					<van-icon class="black" color="#000" size="20px" name="youjiantou"/>
				</p>
			</router-link>
			<router-link tag="li" to='/personal/invoice' class="container border-b20 pt15 pb15 layout">					
				<div class="fs14 black">发票抬头</div>
				<p>
					<span class="fs14 c34">{{ data.invoice }}</span>
					<van-icon class="black" color="#000" size="20px" name="youjiantou"/>
				</p>
			</router-link>
		</ul>

		<van-dialog
		  	v-model="show"
		  	show-cancel-button
		  	:before-close="beforeClose"
			title="提示"
		>
			<van-field
			    v-model="username"
			    placeholder="请输入昵称"
			/>
		 
		</van-dialog>
	</div>
</template>

<script>
import { Uploader,Dialog } from 'vant';
	export default{
		components:
		{
			Uploader,
			Dialog
		},
		data()
		{
			return{
				data 		: [],
				show 		: false,
				username 	: ''
			}
		},
		created()
		{
			this.loadData();
		},
		methods:
		{
			loadData()
			{
				this.$http.get('/user/personal').then(res=> { 
					this.data = res.data;
				})
			},
			onRead(file) {
		      	console.log(file)
		      	this.$http.post('/user/uploadImg',{ img : file }).then(res => {
					// this.img_array.push(res);
				})
		    },
		    beforeClose(action, done) {
			    if (action === 'confirm') {

			    } else {
			        done();
			    }
		    }
		}
	}
</script>

<style lang="less">
	.information {
		.van-dialog__header{
			color:#ea2000;
		}
	}
</style>
